<?php
include_once 'app/until/GFW_database.php';

class GetData extends GDB {

	protected  $con       = null;

	function GetData(){	
	    if(array_key_exists('UserId',$_SESSION)){
	        if(array_key_exists('session_check',$_SESSION)){
    	        if($_SESSION['session_check'] < date('Y-M-D H:i:s', time())){	
    	                        
    	            $con = self::startGDB();
            		$con->Select('UPDATE user_session SET date = now() WHERE user_id ='.$_SESSION['UserId']);
            		
		            $etime = strtotime("+5 minutes", time());
                    $_SESSION['session_check'] = date('Y-M-D H:i:s', $etime);
    	        }
	        }
	        if(isset($_COOKIE['GFW']['UCI'])){            
                $city = new Db_City();
                $selectetcity = $city->getCity($_COOKIE['UserCityId']);
                 
                $_SESSION ['Userlat']    = $selectetcity->lat;
                $_SESSION ['Userlng']    = $selectetcity->lng;
                $_SESSION ['UserCity']   = $selectetcity->name;
                
                HTTP::redirect(ConfigFile::Get('BASE_DIR'));
            }
	        $this->ActivUser = $this->getUserData($_SESSION["UserId"]);
	    }else{
	       HTTP::redirect(ConfigFile::Get('BASE_DIR'));
           die();
	    }
	}

 	public function getUserData($user_id){				
		$con = self::startGDB();
		
		$con->Select('Select * From user where id = '.$user_id);
		$user = $con->fetchobject(1);
		
		return $user;
	}
}

?>